﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Win8Demo.DataModel;
using Win8Demo.Helper;
using Win8Demo.Parser;

namespace Win8Demo.NetWork
{
    public class ServiceManager
    {
        public static NetEngine GetHoneyItemsEngine(string domainName, long minTimestamp, long maxTimestamp, WebCallback callback)
        {
            //ReqEntity
            Dictionary<string, object> paras = new Dictionary<string, object>();
            paras.Add("domainName", domainName);
            paras.Add("p", "WP7");
            paras.Add("limit", 20);
            paras.Add("minTimeStamp", minTimestamp);
            paras.Add("maxTimeStamp", maxTimestamp);
            CommonReqEntity reqEntity = new CommonReqEntity(Constant.HoneyItemsUrl,paras,ReqType.GET);
            //Parser
            HoneyParser honeyParser = new HoneyParser();
            BaseParser baseParser = new BaseParser();
            honeyParser.NextParser = baseParser;
            //ResultData
            Dictionary<string, object> resultData = new Dictionary<string, object>();
            List<HoneyEntity> honeyList = new List<HoneyEntity>();
            ErrorEntity errorEntity = new ErrorEntity();
            resultData.Add("HoneyList", honeyList);
            resultData.Add("ErrorEntity", errorEntity);
            return new NetEngine(reqEntity, honeyParser, resultData, callback);
        }
    }
}
